package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	db,err := sql.Open("mysql","root:123456@tcp(192.168.2.57:3306)/gateway_go?charset=utf8");
	if err != nil{
		fmt.Printf("connect mysql fail ! [%s]",err)
	}else{
		fmt.Println("connect to mysql success")
	}

	rows,err := db.Query("select id,area_name from area");
	if err != nil{
		fmt.Printf("select fail [%s]",err)
	}

	for rows.Next(){
		var id int
		var area_name string
		rows.Columns()
		err := rows.Scan(&id,&area_name)
		if err != nil{
			fmt.Printf("get user info error [%s]",err)
		}
		fmt.Println(id, area_name)
		//mapUser[username] = id
	}

}
